package com.lsyw.intergrate.entity.common;

import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.lsyw.intergrate.entity.MassifUser;
import com.lsyw.intergrate.entity.SysUser;
import lombok.Data;

import java.util.List;

/**
 * @author liulei
 * @version 1.0
 * @date 2022/3/10 9:47
 * 登录返回对象
 */
@Data
public class LoginInfo {
    /**
     * 账户
     */
    private String account;

    /**
     * 账户
     */
    private String userId;

    /**
     * tokenName
     */
    private String tokenName;
    /**
     * token值
     */
    private String tokenValue;
    /**
     * 用户名
     */
    private String name;
    /**
     * 性别
     */
    private String sex;
    /**
     * 权限点集合
     */
    List<String> permissionList;
    /**
     * 角色集合
     */
    List<String> roleList;

    public LoginInfo(SysUser user, SaTokenInfo tokenInfo) {
        this.userId=user.getId();
        this.account=user.getName();
        this.tokenName=tokenInfo.tokenName;
        this.tokenValue=tokenInfo.tokenValue;
        this.name=null;
        this.sex=null;
        this.permissionList=StpUtil.getPermissionList(StpUtil.getLoginId());
        this.roleList=StpUtil.getRoleList(StpUtil.getLoginId());

    }

    public LoginInfo(MassifUser user, SaTokenInfo tokenInfo) {
        this.userId=user.getId();
        this.account=user.getName();
        this.tokenName=tokenInfo.tokenName;
        this.tokenValue=tokenInfo.tokenValue;
        this.name=null;
        this.sex=null;
        this.permissionList=StpUtil.getPermissionList(StpUtil.getLoginId());
        this.roleList=StpUtil.getRoleList(StpUtil.getLoginId());

    }


}